package de.mizi.tilemap.factory;

import java.awt.Color;

import de.mizi.tilemap.creature.Player;
import de.mizi.tilemap.object.LocatableTilemapObject;
import de.mizi.tilemap.object.TilemapObjectDrawData;
import de.mizi.tilemap.tile.Tile;

/**
 * This class shall simplify the creation of new TilemapObjects.
 * @author mizi
 *
 */
public class TilemapObjectFactory {
	/**
	 * The tile id for walls.
	 */
	public static final int WALL_TILE = 0;
	/**
	 * The tile id for the floor.
	 */
	public static final int FLOOR_TILE = 1;
	
	/**
	 * The object id for the cursor object.
	 */
	public static final int CURSOR_OBJECT = 50;
	
	/**
	 * Create a new Tile object depending on the given tile id.
	 * @param tileID the tile id
	 * @return a new Tile object
	 */
	public Tile createTile(int tileID) {
		TilemapObjectDrawData drawData;
		String description;
		boolean isBlocking;
		
		switch(tileID) {
		case WALL_TILE:
			drawData = new TilemapObjectDrawData('#', Color.DARK_GRAY, Color.BLACK);
			description = "Eine Wand.";
			isBlocking = true;
			break;
		case FLOOR_TILE:
			drawData = new TilemapObjectDrawData('.', Color.WHITE, Color.BLACK);
			description = "Nackter Steinfußboden.";
			isBlocking = false;
			break;
		default:
			drawData = new TilemapObjectDrawData('?', Color.RED, Color.BLACK);
			description = "unbekannt";
			isBlocking = false;
		}
		
		return new Tile(drawData, description, isBlocking);
	}
	
	/**
	 * Constructs a new Player object at the given position.
	 * @param x the x position
	 * @param y the y position
	 * @return the new player object
	 */
	public Player createPlayer(int x, int y) {
		return new Player(x, y, new TilemapObjectDrawData('@', Color.WHITE, Color.BLACK), "Der Held vom Erdbeerfeld.");
	}
	
	/**
	 * Constructs a new special object at the given position.
	 * @param objectID the id of the object
	 * @param x the x position
	 * @param y the y position
	 * @return the special object
	 */
	public LocatableTilemapObject createSpecialObject(int objectID, int x, int y) {
		TilemapObjectDrawData drawData;
		String description;
		
		switch(objectID) {
		case CURSOR_OBJECT:
			drawData = new TilemapObjectDrawData('@', Color.GREEN, Color.BLACK);
			description = "";
			break;
		default:
			drawData = new TilemapObjectDrawData('?', Color.RED, Color.BLACK);
			description = "unbekannt";
		}
		
		return new LocatableTilemapObject(x, y, drawData, description);
	}
}
